package com.qf.service;

import com.qf.mapper.UserDao;
import com.qf.mapper.UserDaoImpl;
import com.qf.entity.User;

public class UserServiceImpl implements UserService {
    @Override
    public User login(String userName, String password) {
        //根据用户名到数据库查询数据
        UserDao userDao = (UserDao) new UserDaoImpl();
        User user = userDao.findByUserName(userName);

        //判断用户是否为空，若为空 用户名错误
        if (user == null){
            return  null;
        }
        if (password.equals(user.getPassword())){
            return user;
        }
        return null;
    }

    @Override
    public int addUser(User user) {
        UserDao userDao = new UserDaoImpl();
        int count = userDao.addUser(user);

        return count;
    }

}
